#ifndef MAP_H
#define MAP_H

#include "OuterRegion.h"
#include "MiddleRegion.h"
#include "InnerRegion.h"
#include "Space.h"
#include <utility>
#include <qimage.h>

#include <qwidget.h>
#include <qgridlayout.h>
#include <qlabel.h>
#include <qpushbutton.h>

#include "PositionKeeper.h"

namespace talisman_map 
{
class Map  : public QWidget
{
public:
	Map(PlayerCharacter * iPlayer, PositionKeeper * iPositionKeeper, QWidget * parent = 0);
	virtual ~Map();
	inline Space * getOuterRegionStartSpace(void) const {return mOuterRegion.getStartSpace(); };
	inline Space * getMiddleRegionStartSpace(void) const {return mMiddleRegion.getStartSpace(); }; 
	inline Space * getInnerRegionStartSpace(void) const {return mInnerRegion.getStartSpace(); }; 
	void updateContents(void);
	void setup(void);
	void init(std::string iMapConfigFileName);
	void setPlayer(PlayerCharacter *iNewPlayer) ;	

protected:
	void paintEvent (QPaintEvent *event) override;
	

private:
	bool pref(string str, string pref) const;
	OuterRegion mOuterRegion;
	MiddleRegion mMiddleRegion;
	InnerRegion mInnerRegion;

	QImage *background;
	QGridLayout *layout;

	PositionKeeper* mPositionKeeper;
	PlayerCharacter *mPlayer;

	bool mInitOk;
};
}


#endif